package com.twu.biblioteca.commands;

import com.google.common.base.Optional;
import com.twu.biblioteca.Biblioteca;
import com.twu.biblioteca.UserInformation;

import java.io.InputStream;
import java.io.PrintStream;

public class UserInformationCommand extends BibliotecaCommand {
    public UserInformationCommand(InputStream input, PrintStream output, Biblioteca biblioteca) {
        super("Your Information", input, output, biblioteca);
    }

    public boolean run() {
        if (!biblioteca.isLoggedIn()) {
            output.println(NOT_LOGGED_IN);
            return false;
        }

        Optional<UserInformation> information = biblioteca.getCurrentUserInformation();

        output.println("Name:  " + information.get().getName());
        output.println("Email: " + information.get().getEmailAddress());
        output.println("Phone: " + information.get().getPhoneNumber());

        return false;
    }
}
